package com.serverSite;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Date;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class ClientTest {
	public static void main(String[] args) throws JSONException {
		int port = 10001;
		String ip = "127.0.0.1";
		JSONObject jso = new JSONObject();
		jso.put("message", "book");
		jso.put("productId", 1);
		jso.put("wantedQty", 1);
		try {
			Socket soc = new Socket(ip,port);
			InputStreamReader isr = new InputStreamReader(soc.getInputStream());
			BufferedReader in = new BufferedReader(isr);
			PrintWriter out = new PrintWriter(soc.getOutputStream(),true);
			out.println(jso);
			while(!in.ready());
			String line = in.readLine();
			System.out.println("############## line = "+line);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}